﻿using ReflectionStudio.Core.Events;
using System;
using System.Data;
using System.Windows;
using System.Windows.Data;
using WPFExcelReport.Helpers;
using System.ComponentModel;
namespace WPFExcelReport
{
    public partial class TNGS : UIGSDAT
    {

        public TNGS()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VGSDAT();
            DataContext = MV;
            InitializeComponent();
        }
        public override void LOAD()
        {
            base.LOAD();
            if (CART.Length < 20)
                return;
            if (!IsAutoGS) return;

            if (TBMain.Rows.Count > 0) return;
            dwData = TBMain.NewRow();
            ((VGSDAT)MV).SetUpNewRow(ref dwData);
            dwData["GSMANDANT"] = app.Mandant;
            dwData["GSART"] = CART.Substring(0, 20);
            dwData["GSVAR"] = Helper.Left(CART.Substring(20).PadRight(3), 3);
            SResult = ((VGSDAT)MV).QueryGSDAT(dwData, 1);           
            if (SResult.Tables[0].Rows.Count > 0)
            {
                MergeData(SResult, true);
                return;
            }
            Insert(dwData);
         }
    }
}
